/*------------------------------------------------------------------------------
 * PROJ : Prototype
 * NAME : sculove.spring.zzz.login.service.LoginServiceImpl.java
 *        
 * Copyright 2009 sculove All rights reserved
 *------------------------------------------------------------------------------
 */
package sculove.spring.zzz.login.service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import sculove.spring.framework.util.AuthUtil;
import sculove.spring.zzz.login.dao.UserDAO;
import sculove.spring.zzz.login.model.UserDTO;

/**
 * <pre>
 * sculove.spring.zzz.login.service.LoginServiceImpl.java
 * 
 * TODO
 * 
 * </pre>
 * 
 * @date : 2009. 11. 28. 오후 7:59:13
 * @version :
 * @author : sculove
 */
@Service("zzz.loginService")
public class LoginServiceImpl implements LoginService {
	@Resource(name="zzz.userDAO")
	private UserDAO userDao;
	
	public UserDAO getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDAO userDao) {
		this.userDao = userDao;
	}

	@Override
	public boolean login(HttpServletRequest request, UserDTO inDto) throws Exception {
		// DB조회
		UserDTO outDto = userDao.inqUser(inDto);
		if(outDto != null) {
			// Session 생성
			AuthUtil.setSession(request, outDto);
			return true;
		} else {
			return false;
		}
	}

	@Override
	public void logout(HttpServletRequest request) throws Exception {
		AuthUtil.removeSession(request);
	}
}
